import { ElMessage } from 'element-plus';
import { pluginManager, type PublicMethodModel } from 'epic-designer';

const messageBox: PublicMethodModel = {
  name: 'messageBox',
  handler: (data: { message: string; type: string }) => {
    switch (data.type) {
      case 'success': {
        ElMessage.success(data.message);
        break;
      }
      case 'error': {
        ElMessage.error(data.message);
        break;
      }
      case 'warning': {
        ElMessage.warning(data.message);
        break;
      }
      default: {
        ElMessage.info(data.message);
        break;
      }
    }
  },
  describe: '发送消息',
};
export function setupPublicMethod(): void {
  pluginManager.addPublicMethod(messageBox);
}
